import Vue from 'vue'
import App from './App.vue'
import axios from 'axios'
import router from './router/router.js'
// 引入组件库
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import { Loading } from 'element-ui'

Vue.use(ElementUI);
// 导入路由模块

Vue.config.productionTip = false
    // 配置axios

Vue.prototype.$http = axios
axios.defaults.baseURL = 'http://localhost:3000'
    // 声明请求拦截器
let loadingInstance = null
axios.interceptors.request.use((config) => {
        //展示loading效果
        loadingInstance = Loading.service({ fullscreen: true })

        return config
    })
    // 声明响应拦截器
axios.interceptors.response.use((response) => {
    // 关闭loading效果
    loadingInstance.close()
    return response
})
new Vue({
    render: h => h(App),
    router
}).$mount('#app')